package ahpu.piconet.service.impl;

import java.util.Date;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.google.gson.Gson;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;

import ahpu.piconet.dao.DataDao;
import ahpu.piconet.domin.Data;
import ahpu.piconet.service.DataService;

@Service
public class DataServiceImpl implements DataService {

	@Autowired
	private DataDao dataDao;

	@Override
	public void saveData(float electricity, float voltage) {
		Data data = new Data();
		data.setElectricity(electricity);
		data.setVoltage(voltage);
		data.setTimer(new Date());
		dataDao.addData(data);
	}

	@Override
	public List<Data> findByDate(String start, String end, int limit, int page) {
		return dataDao.findByDate(start, end, limit, page);
	}

	@Override
	public int findAllCount() {
		return dataDao.findAllCount();
	}

	@Override
	public List<Data> findByLimit(int limit, int page) {
		
		return dataDao.findByLimit(limit, page);
	}
	


	@Override
	public Data findById(Integer id) {
		return dataDao.findById(id);
	}

	@Override
	public int findCountByLimit(String start, String end) {

		return dataDao.findCountByDate(start, end);
	}

	@Override
	public List<Data> queryExportedForestry(String[] ids) {
		return dataDao.queryExportedForestry(ids);
	}

}
